1
From Recurrence to Attention: Addressing Sequential Modeling Limitations
EvoClass-AI003 Lecture 6
00:00

From Recurrence to Attention: Addressing Sequential Modeling Limitations

Traditional sequential modeling relied heavily on Recurrent Neural Networks (RNNs) and their gated variants (LSTMs, GRUs). While groundbreaking for early sequence-to-sequence tasks, these architectures suffer from fundamental scalability issues when handling extensive dependencies. The introduction of attention mechanisms provided the essential conceptual breakthrough required to move beyond these limitations and enable modern, highly effective NLP systems.

1. The Long-Range Dependency Problem

In RNNs, the dependency path between token $t_i$ and token $t_j$ must traverse all intermediate steps sequentially. This forces the gradient signal during backpropagation to repeatedly multiply through weight matrices, leading to the rapid decay (vanishing gradient) of the signal, which makes it nearly impossible to propagate useful information or error signals across long distances in the sequence. The path complexity is $O(N)$.

2. The Fixed-Size Context Bottleneck

Standard encoder-decoder architectures prior to attention required the entire meaning of the source sequence, regardless of length, to be compressed into a single, fixed-dimension vector (the context vector, $C$). This bottleneck severely limits the capacity of the model to retain all necessary information, especially for long or complex inputs, resulting in critical information loss during the decoding phase.

Conceptual Representation
Question 1
Why is the dependency path length in a standard RNN considered a major limitation for long sequences?
Path complexity is $O(1)$.
Path complexity is $O(N^2)$.
Path complexity is $O(N)$, causing vanishing gradients.
It prevents the use of LSTMs.
Question 2
In pre-Attention Seq2Seq models, what component represents the 'information bottleneck'?
The softmax layer.
The recurrent cell (e.g., GRU).
The fixed-size context vector derived from the encoder's final hidden state.
The input embedding layer.
Challenge: Conceptualizing Attention's Advantage
Comparing Structural Complexity
Consider a sequence of length $N$. We want to establish a dependency between token $X_i$ and token $Y_j$.

Contrast the dependency path length required by:
  • Traditional Recurrence (e.g., LSTM)
  • Attention Mechanism (Query-Key comparison)
Step 1
How does Attention fundamentally reduce the structural complexity of establishing distant dependencies?
Solution:
Attention creates a direct, non-sequential connection between any output token $Y_j$ and any input token $X_i$ by calculating a weight based on their vector similarity ($Q_j K_i^T$). The dependency path length is effectively $O(1)$ (a direct look-up), removing the constraint of linear path traversal imposed by recurrence ($O(N)$).